package com.wondertek.web.controller.business;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wondertek.common.base.Result;
import com.wondertek.service.dto.business.req.AlarmNoticeSettingAddReq;
import com.wondertek.service.dto.business.req.AlarmNoticeSettingQueryReq;
import com.wondertek.service.dto.business.req.AlarmNoticeSettingUpdateReq;
import com.wondertek.service.entity.business.AlarmNoticeSettingPo;
import com.wondertek.service.service.business.IAlarmNoticeSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 报警通知设置管理
 */
@RestController
@RequestMapping("/backend/business/alarm-notice-setting")
@Tag(name = "报警通知设置管理")
public class AlarmNoticeSettingController {

    @Resource
    private IAlarmNoticeSettingService alarmNoticeSettingService;


    /**
     * 分页查询报警通知设置
     */
    @PostMapping("/page")
    @Operation(summary = "分页查询报警通知设置")
    public Result<Page<AlarmNoticeSettingPo>> page(@RequestBody @Validated AlarmNoticeSettingQueryReq alarmNoticeSettingQueryReq) {
        return Result.success(alarmNoticeSettingService.page(alarmNoticeSettingQueryReq));
    }

    /**
     * 新增报警通知设置
     */
    @PostMapping("/add")
    @Operation(summary = "新增报警通知设置")
    public Result<?> save(@RequestBody @Validated AlarmNoticeSettingAddReq alarmNoticeSettingAddReq) {
        alarmNoticeSettingService.add(alarmNoticeSettingAddReq);
        return Result.success();
    }

    /**
     * 修改报警通知设置
     */
    @PostMapping("/update")
    @Operation(summary = "修改报警通知设置")
    public Result<?> update(@RequestBody @Validated AlarmNoticeSettingUpdateReq alarmNoticeSettingUpdateReq) {
        alarmNoticeSettingService.updateSysJob(alarmNoticeSettingUpdateReq);
        return Result.success();
    }

    /**
     * 删除报警通知设置
     */
    @PostMapping(value = "/delete")
    @Operation(summary = "删除报警通知设置")
    public Result<?> del(@RequestParam("id") String id) {
        alarmNoticeSettingService.removeById(id);
        return Result.success();
    }

}
